<template>
  <div>
    <el-dialog
      title="添加数据"
      :visible.sync="dialogVisible"
      center
      width="80%"
      :before-close="handleClose">
      <el-card>
        <el-form ref="form" :rules="rules" :model="form" label-width="100px">
          <el-row :gutter="24">
            <el-col :span="5">
              <el-form-item label="名称" prop="xName" required>
                <el-input v-model="form.xName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="序号" prop="xNumber">
               <el-input-number v-model="form.xNumber" @change="handleChange" :min="1" :max="10" label="描述文字" size="mini" ></el-input-number>
               </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="人数" prop="xCount" required>
                <el-input v-model="form.xCount"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="7">
              <el-form-item label="状态" prop="xDescription" required>
                  <el-select v-model="form.xDescription" placeholder="请选择当前状态">
                   <el-option v-for="item in returnResultList" :key="item.code" :label="item.name" :value="item.code"></el-option>
                  </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              
          <el-form-item label="备注" prop="xBeizhu">
            <el-input type="textarea" v-model="form.xBeizhu"></el-input>
          </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="7">
                <el-form-item label="日期" prop="xDate" size="mini">
                <el-date-picker
      v-model="form.xDate"
      type="datetime"
      placeholder="选择日期">
    </el-date-picker>
            </el-form-item>
           
            </el-col>
            <el-col :span="6">
              <el-form-item label="性别" prop="xSex">
  <el-radio v-model="form.xSex" label="男" value="1">男</el-radio>
  <el-radio v-model="form.xSex" label="女" value="2">女</el-radio>

              </el-form-item>
            </el-col>

            <el-col :span="6">
              <el-form-item label="根节点id" prop="fGroupId">
  <mdm-material v-if="!isLoading" ref="search_material" v-model="form.fGroupId" :loadShow="form.fGroupId" >
                    
                  </mdm-material>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm()">提交</el-button>
        <el-button @click=" handleClose()">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import xuTest1 from "@/api/customer/xuTest1";

export default {
  name: "add_xu",
  components:{
    xuTest1
  },
  data() {
    return {
      disabledDate(time) {
          return time.getTime() > Date.now()
        },
         value1: '',
      dialogVisible: true,
      form: {
        xName: '',
        xBeizhu: '',
        xNumber: '',
        xDescription: '',
        xCount:'',
        xSex:'',
        xDate:'',
        fGroupId: 0
      },
      tableData: [],
      returnResultList:[],
      rules: {
        xname: [
          {required: true, message: '请输入名称', trigger: 'blur'},
          {max: 16, message: '长度在 16字符', trigger: 'blur'}
        ],
       xCount: [{required: true, message: '请输入人数', trigger: 'blur'}],
       xDerscription: [{required:true,message:'请选择状态',trigger:'blur'}]
      }
    };
    
  },
  async created(){
    let http = new xuTest1()
    let  returnResultList = await http.getEnum({sysName:"tie-demo",className:"cn.hxlc.tie.demo.core.enums.StatusEnum"})
    this.returnResultList = returnResultList.data;
  },
  
  methods: {
    handleClose() {
      this.$emit("close", {name: 'add', isRefresh: false}
      );
    },
    handleChange(value) {
        console.log(value);
      },
    submitForm() {
      this.$refs['form'].validate((valid) => {
        this.form.workShopEntityParam=this.tableData
        console.log(this.xuTest1)
        if (valid) {
          const loading = this._loading();
          const api = new xuTest1();
          api.add(this.form).then(res => {
            loading.close();
            this.$tie.showSuccess(res.message)
            this.$emit("close", {name: 'add', isRefresh: true});
          }).catch(e => loading.close())
        }

        return false;
      })
    },
    handle_del(index, row) {
      this.tableData.splice(index, 1);
    },
    handle_insert() {
      const newValue = {
        fname: '',
        fstatus: '',
        fnumber: '',
        foid: ''
      };
      this.tableData.push(newValue)
    }
    ,
    //加载提示
    _loading() {
      return this.$loading({
        lock: true,
        text: '请耐心等待.....',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
    }
  }
}
</script>

<style scoped>

</style>
